<?php

namespace backend\controllers;

use Yii;
use yii\web\Controller;

use common\components\Word;
use common\models\Menu;
/**
 * 后台公用控制器
 */
class AdminController extends Controller
{

	public function init(){

	}

	/**
	 * 获取菜单栏
	 * @param $controller  当前控制器
	 * @param $action    当前操作方法
	 */
	public static function getGroup($controller, $action){
		$url = $controller . '/' . $action;
		$model = Menu::find();
		$data  = $model->where('url = :url and status = 1', [':url' => $url])->one();
		$list = $model->orderBy('sort')->where("groups = '{$data->groups}' and status = 1 and hide = 0")->all();

		return Word::tree($list);
	}


}
